local sk_le__angyang = fk.CreateSkill {

  name = "sk_le__angyang",

  tags = {},

}
Fk:loadTranslationTable {
  ['sk_le__angyang'] = '昂扬',
  [':sk_le__angyang'] = '当你使用【杀】/【决斗】指定一名其他角色为目标后，或成为其他角色使用这些牌的目标后，你可以获得对方一张手牌，此牌结算后，若其有手牌，你视为对其使用一张【决斗】/[杀】。',
  ['$sk_le__angyang1'] = '江东子弟，何惧于天下',
  ['$sk_le__angyang2'] = '当世豪杰，我等必扬名',
  ['#sk_le__angyang'] = '昂扬:你可以获得其一张手牌',
  ['#sk_le__angyang-invoke'] = '昂扬:是否视为对其使用一张【%arg】',
}


sk_le__angyang:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk_le__angyang.name) and data.card and data.to ~= player
        and (data.card.trueName == 'slash' or data.card.trueName == 'duel') and data.to:getHandcardNum() > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cid = room:askToChooseCard(player, {
      target = data.to,
      flag = "h",
      skill_name = "sk_le__angyang",
      prompt = "#sk_le__angyang",
    })
    room:obtainCard(player, cid, false, fk.ReasonPrey, player, "sk_le__angyang")
    room:addTableMark(player, "sk_le__angyang_used", data.to)
  end,
})

sk_le__angyang:addEffect(fk.TargetConfirmed, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player == target and player:hasSkill(sk_le__angyang.name) and data.card and data.from ~= player
        and (data.card.trueName == 'slash' or data.card.trueName == 'duel') and data.from:getHandcardNum() > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cid = room:askToChooseCard(player, {
      target = data.from,
      flag = "h",
      skill_name = "sk_le__angyang",
      prompt = "#sk_le__angyang",
    })
    room:obtainCard(player, cid, false, fk.ReasonPrey, player, "sk_le__angyang")
    room:setPlayerMark(player, "sk_le__angyang_used", { data.from })
  end,
})

sk_le__angyang:addEffect(fk.CardUseFinished, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill("sk_le__angyang") and data.card and #player:getTableMark("sk_le__angyang_used") > 0
        and (data.card.trueName == 'slash' or data.card.trueName == 'duel') and
        ((target ~= player and target:isAlive() and target:getHandcardNum() > 0) or
          (target == player and table.find(data.tos, function(other, index, array)
            return other ~= player and other:getHandcardNum() > 0 and other:isAlive()
          end)))
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "sk_le__angyang_used", 0)
    return room:askToSkillInvoke(player, {
      skill_name = self.name,
      prompt = "#sk_le__angyang-invoke:::" .. Fk:translate(data.card.trueName == "slash" and "duel" or "slash"),
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "sk_le__angyang_used", 0)
    local targets
    if target ~= player then
      targets = { target }
    else
      targets = table.filter(data.tos, function(other, index, array)
        return other ~= player and other:getHandcardNum() > 0
      end)
    end
    local card_name = data.card.trueName == 'slash' and "duel" or "slash"
    if #targets > 0 then
      room:useVirtualCard(card_name, nil, player, targets, "sk_le__angyang", true)
    end
  end,
})

return sk_le__angyang
